// 创建stores
const useStores = defineStore('shop',() => {
    const business = ref({});

    const $BusinessReset = () => {
        business.value = {};
    }

    return {
        business,
        $BusinessReset
    }
},{
    persist:{
        key:'shop',// 给一个要保存的名称
        storage:localStorage,// sessionStorage || localStorage 存储方式
    }
})

export default {
    install(app)
    {
        // 初始化
        const store = useStores();

        // 提取store数据是一个ref定义响应式
        const { business } = storeToRefs(store);
       
        // 挂载到全局中
        app.config.globalProperties.$business = business;
        app.config.globalProperties.$store = store;
    }
}